package com.gamatechno.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import com.gamatechno.solodestination.JournalPerjalananFragment;

import com.gamatechno.solodestination.R;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class JournalAdapter extends BaseAdapter{
	
	private Activity activity;
	private ArrayList<HashMap<String, String>> data;
	private static LayoutInflater inflater;
	
	
	public JournalAdapter(Activity a, ArrayList<HashMap<String, String>> d){
		activity = a;
		data = d;
		inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View vi = convertView;
		if(convertView == null)
			vi = inflater.inflate(R.layout.row_journalperjalanan, null);
		TextView lokasi = (TextView) vi.findViewById(R.id.lokasi);
		TextView kategori = (TextView) vi.findViewById(R.id.kategori);
		TextView tgl = (TextView) vi.findViewById(R.id.tanggal);
		TextView bln = (TextView) vi.findViewById(R.id.bulan);
		TextView komen = (TextView) vi.findViewById(R.id.komen_jurnal);
		
		HashMap<String, String> artefact = new HashMap<String, String>();
		artefact = data.get(position);
		
		
		Log.d("ARTEFACT", artefact.toString());
		lokasi.setText(artefact.get(JournalPerjalananFragment.KEY_LOKASI));
		kategori.setText(artefact.get(JournalPerjalananFragment.KEY_KATEGORI));
		tgl.setText(artefact.get(JournalPerjalananFragment.KEY_TGL));
		bln.setText(artefact.get(JournalPerjalananFragment.KEY_BLN));
		komen.setText("\""+artefact.get(JournalPerjalananFragment.KEY_KOMEN)+"\"");
		return vi;
	}

}
